#ifndef __WXSSTYLE_H
#define __WXSSTYLE_H

#include "../wxscodinglang.h"
#include <wx/dynarray.h>
#include <wx/arrstr.h>

const long wxsSFXRC    = 0x00000001;
const long wxsSFWin    = 0x00000002;
const long wxsSFWin95  = 0x00000004;
const long wxsSFWinCE  = 0x00000008;
const long wxsSFGTK    = 0x00000010;
const long wxsSFGTK12  = 0x00000020;
const long wxsSFGTK20  = 0x00000040;
const long wxsSFOSX    = 0x00000080;
const long wxsSFCOCOA  = 0x00000100;
const long wxsSFCARBON = 0x00000200;
const long wxsSFMotif  = 0x00000400;
const long wxsSFMGL    = 0x00000800;
const long wxsSFOS2    = 0x00001000;
const long wxsSFX11    = 0x00002000;
const long wxsSFPALMOS = 0x00004000;
const long wxsSFUNIV   = 0x00008000;
const long wxsSFAll    = 0x0000FFFF;
const long wxsSFExt    = 0x80000000;

struct wxsStyle {
  wxString Name;
  long Value;
  long Flags;
  inline bool IsCategory() const { return Value == ( ( long ) - 1 ); }
  inline bool IsExtra() const { return ( Flags & wxsSFExt ) != 0; }
};

class wxsStyleSet {
  public:
    wxsStyleSet( const wxChar* DefaultStyle = _T( "" ) );
    void AddStyle( const wxChar* Name, long Value, long Flags );
    void EndStyle();
    ~wxsStyleSet();
    inline const wxArrayString& GetNames( bool IsExtra ) const { return IsExtra ? ExStyleNames : StyleNames; }
    inline const wxArrayLong& GetBits( bool IsExtra ) const { return IsExtra ? ExStyleBits : StyleBits; }
    inline const wxArrayLong& GetValues( bool IsExtra ) const { return IsExtra ? ExStyleValues : StyleValues; }
    inline const wxArrayLong& GetFlags( bool IsExtra ) const { return IsExtra ? ExStyleFlags : StyleFlags; }
    inline long GetDefaultBits( bool IsExtra ) const { return IsExtra ? 0 : Default; }
    long GetBits( const wxString& Style, bool IsExtra ) const;
    wxString GetString( long Bits, bool IsExtra, wxsCodingLang Language ) const;
    long GetWxStyle( long StyleBits, bool IsExtra = false ) const;
  private:
    const wxChar* DefaultStr;
    long Default;
    wxArrayString StyleNames;
    wxArrayLong StyleBits;
    wxArrayLong StyleValues;
    wxArrayLong StyleFlags;
    wxArrayString ExStyleNames;
    wxArrayLong ExStyleBits;
    wxArrayLong ExStyleValues;
    wxArrayLong ExStyleFlags;
};

#define WXS_ST_BEGIN(name,DefaultStyle)                             \
  const wxsStyleSet* Get##name##StyleSet();                       \
  static const wxsStyleSet* name = Get##name##StyleSet();         \
  const wxsStyleSet* Get##name##StyleSet()                        \
  {                                                               \
    static wxsStyleSet Set(DefaultStyle);                       \


#define WXS_ST(name)                                                \
  Set.AddStyle(_T(#name), name, wxsSFAll & ~wxsSFExt);


#define WXS_EXST(name)                                              \
  Set.AddStyle(_T(#name), name, wxsSFAll | wxsSFExt);


#define WXS_ST_MASK(name,Include,Exclude,InXRC)                     \
  Set.AddStyle(_T(#name), name,                               \
               ((Include) & (~(Exclude)) & (~(wxsSFExt|wxsSFXRC))) |   \
               ((InXRC) ? wxsSFXRC : 0 ) );


#define WXS_EXST_MASK(name,Include,Exclude,InXRC)                   \
  Set.AddStyle(_T(#name), name,                               \
               ((Include) & (~(Exclude)) & (~wxsSFXRC)) |              \
               ((InXRC) ? wxsSFXRC : 0 ) | wxsSFExt );

#define WXS_ST_CATEGORY(name)                                       \
  Set.AddStyle(_T(#name),-1, 0);

#define WXS_ST_END()                                                \
  Set.EndStyle();                                             \
  return &Set;                                                \
  }

#define WXS_ST_DEFAULTS()  \
  Set.AddStyle(_T("wxWindow"),-1, 0);\
  Set.AddStyle(_T("窗口瘦边框"), wxSIMPLE_BORDER, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("窗口双层边框"), wxDOUBLE_BORDER, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("窗口凹陷边框"), wxSUNKEN_BORDER, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("窗口凸起边框"), wxRAISED_BORDER, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("窗口适合静态控件边框-win"), wxSTATIC_BORDER, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("窗口无边框"), wxNO_BORDER, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("窗口透明-win"), wxTRANSPARENT_WINDOW, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("窗口支持TAB键遍历"), wxTAB_TRAVERSAL, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("窗口允许特殊按键事件"), wxWANTS_CHARS, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("wxNO_FULL_REPAINT_ON_RESIZE"), wxNO_FULL_REPAINT_ON_RESIZE, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("窗口垂直滚动条"), wxVSCROLL, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("窗口水平滚动条"), wxHSCROLL, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("窗口智能滚动条-win"), wxALWAYS_SHOW_SB, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("窗口消除闪铄-win"), wxCLIP_CHILDREN, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("窗口重绘"), wxFULL_REPAINT_ON_RESIZE, wxsSFAll & ~wxsSFExt);\
  Set.AddStyle(_T("wxWS_EX_BLOCK_EVENTS"), wxWS_EX_BLOCK_EVENTS, wxsSFAll | wxsSFExt);\
  Set.AddStyle(_T("wxWS_EX_VALIDATE_RECURSIVELY"), wxWS_EX_VALIDATE_RECURSIVELY, wxsSFAll | wxsSFExt);

#endif
